$(function(){
    $("#productInfo_datagrid").datagrid({
        url:"/storages/list?state=1",
        fitColumns: true,
        fit: true,
        rownumbers: true,
        singleSelect:true,
        striped: true,
        columns: [[
            {field: 'ck', checkbox: true},
            {field: 'id', title: '编号', hidden: true, width: 100},
            {field: 'clients', title: '投保人', width: 100 ,formatter: function (value, row, index) {
                return value? value.clientname:"";
            }},
            {field: 'numbers', title: '保险单号', width: 100, align: 'right'},
            {field: 'limits', title: '保费金额', width: 100, align: 'right'},
            {field: 'put', title: '申请日期', width: 100},
            {field: 'durations', title: '保险年限', width: 100},
            {field: 'method', title: '缴费方式', width: 100},
            {field: 'paymentTime', title: '起保时间', width: 100},
            {field: 'agencyInfos', title: '保险机构', width: 100 ,formatter: function (value, row, index) {
                return value? "<p>"+value.name+"</p>" : "<p>有bug</p>";
            }},
            {field: 'employees', title: '业务员', width: 100 ,formatter: function (value, row, index) {
                return value? value.username:"";
            }}
        ]],
        pagination: true,
        toolbar: "#tb",

    });
    //初始化对话框
    $("#my_dialog").dialog({
        width: 600,
        height: 600,
        closed: true
    })
    //初始化对话框-end
})
//查看详情
function query(){
    var row = $("#productInfo_datagrid").datagrid("getSelected");
    if (!row) {
        $.messager.alert('温馨提示', '亲,请先选中你要查的数据');
        return;
    }
    $("#my_productInfos").datagrid({
        url: "/storages/list?state=1",
        fitColumns: true,
        rownumbers: true,
        width:300,
        striped: true,
        title:"已购产品列表",
        columns: [[
            {
                field: 'productInfos', title: '保险机构', width: 100, formatter: function (value, row, index) {
                return value ? value.name : "";
            }
            },
            {field: 'limits', title: '投保总额度', width: 100, align: 'right'}
        ]],
    })
    //清空以前的数据
    $("#editForm").form("clear");
    row["clients.clientname"] = row.clients.clientname;
    row["agencyInfos.name"] = row.agencyInfos.name;
    //数据回显:同名原则
    $("#editForm").form("load",row);
    //对话框显示
    $("#my_dialog").dialog("open");
    //修改对话框标题
    $("#my_dialog").dialog("setTitle", "缴费处理单详情")

}





//刷新
function refresh() {
    //重载
    $("#productInfo_datagrid").datagrid("reload");
}
//高级查询
function querys() {
    var kw = $("#keyword").textbox("getValue");
    $("#productInfo_datagrid").datagrid("load", {
        keyword: kw
    })
}


